<?php
/*
 * wrapper for phpmailer class
 * @author Vladimir Miroshnichenko
 */
class Mailer
{
   var $mail = "";

   function Mailer()
   {
        $this->mail = new PHPMailer();
        
	$this->mail->IsSMTP();
        $this->mail->IsHTML(true);                             // send as HTML
        $this->mail->SMTPAuth   = true;                  // enable SMTP authentication
        $this->mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
        $this->mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
        $this->mail->Port       = 465;                   // set the SMTP port for the GMAIL server
        $this->mail->Username   = GMAIL_LOGIN;           // "csnywebres@gmail.com"; - GMAIL username
        $this->mail->Password   = GMAIL_PASS;		 // "csny8758200";          - GMAIL password
        $this->mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
	
	/*
	$this->mail->IsMail();
        $this->mail->IsHTML(true); // send as HTML
        $this->mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
	*/
   }
      
   function IsSMTP() 
   {
        $this->mail->Mailer = 'smtp';
   }

   function IsMail() 
   {
        $this->mail->Mailer = 'mail';
   }

   function IsSendmail() 
   {
        $this->mail->Mailer = 'sendmail';
   }

   function IsQmail() 
   {
        $this->mail->Sendmail = '/var/qmail/bin/sendmail';
        $this->mail->Mailer   = 'sendmail';
   }
   
   function setFrom($email,$name)
   {
        $this->mail->From       = $email;
        $this->mail->FromName   = $name;
   }
   
   function AddReplyTo($email,$name="")
   {
        $this->mail->AddReplyTo($email,$name);   
   }

   function setSubject($subject)
   {
        $this->mail->Subject = $subject;
   }
    
   function setBody($body)
   {
        $this->mail->MsgHTML($body);       
   }

   function  AddStringAttachment($text,$filename)
   {
        $this->mail->AddStringAttachment($text,$filename);       
   }

   function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') 
   {
        $this->mail->AddAttachment($path, $name, $encoding, $type);                
   }

   function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') 
   {
        $this->mail->AddEmbeddedImage($path, $cid, $name, $encoding, $type);
   }
   
   function AddAddress($email,$name='')
   {
        $this->mail->AddAddress($email,$name);           
   }

   function AddCC($email, $name = '')
   {
       $this->mail->AddCC($email,$name);
   }
   
   function send()
   {
        return $this->mail->Send(); 
   }
   
   function getError()
   {
        return $this->mail->ErrorInfo;
   }
   
   function setPriority($priority)
   {
       $this->mail->Priority = $priority;
   }   
}
?>